var Contact = Backbone.Model.extend({
    defaults: {
    }
});

var ContactList = Backbone.Collection.extend({
    model: Contact
});

var ContactView = Backbone.View.extend({
    tagname: 'li',
    
    events: {
        click: 'showContactDetails'
    },
    
    template: _.template($('#contact-list-template').html()),
    
    render: function () {
        this.$el.html(this.template({contacts: this.collection.toJSON()}));
        return this;
    },
    
    showContactDetails: function() {
        var contactTemplate = _.template($('#contact-details-template').html());
        alert(this.model.get('name'));
//        $('section').html(contactTemplate({contact: this.model.toJSON()}));
    }
});

var newContactList = new ContactList([
    {
        "name": "Bruno Hammond",
        "phone": "(01) 0820 8038",
        "email": "dui@a.co.uk",
        "company": "Cras Eu Corp.",
        "address": "P.O. Box 734, 4764 Malesuada Street",
        "city": "Burnaby",
        "zip": "18492-683"
    },
    {
        "name": "Brandon Cruz",
        "phone": "(09) 5405 7948",
        "email": "malesuada.Integer.id@turpis.org",
        "company": "Diam Institute",
        "address": "5257 Consectetuer Road",
        "city": "Buzet",
        "zip": "892627"
    },
    {
        "name": "Wayne Johnson",
        "phone": "(06) 9550 5174",
        "email": "dolor.quam.elementum@tempusrisus.net",
        "company": "Nunc Ac Sem Institute",
        "address": "Ap #191-6598 Gravida Avenue",
        "city": "Baie-d'Urf�",
        "zip": "H7L 6S6"
    },
    {
        "name": "Gage Hawkins",
        "phone": "(05) 0016 6967",
        "email": "ipsum@sed.co.uk",
        "company": "Faucibus Corporation",
        "address": "193-8593 Etiam Road",
        "city": "Pretoro",
        "zip": "20200"
    }
]);

var newContactView = new ContactView({
    collection: newContactList,
    el: '#contact-list'
});

newContactView.render();


setTimeout(function(){$(function(){alert("test")})},500);